<template>
  <div class="app-container">
    <tl-list-toolbar ref="toolbar" @add="openAddDialog('editForm')" :isDisplayExport="false" @exportExcel="doExportExcel" @deleteBatch="doDeleteBatch" @refresh="doRefresh" @columnCustomize="doColumnCustomize" @displaySearch="doDisplaySearch" :disableDeleteBatch="selectedRowKeys.length <= 0">
      <template slot="left-btn"> </template>
    </tl-list-toolbar>
    <div>
      <!-- 列表选择 -->
      <div class="table-alert-div" ref="selector">
        <el-alert type="success" :closable="false" class="tl-table-alert-info" effect="light">
          <template slot="title">
            已选择&nbsp;<a class="tl-table-alert-info-a1">{{ selectedRowKeys.length }}</a>项&nbsp;&nbsp;
            <a class="tl-table-alert-info-a2" @click="doClearSelected">全部清空</a>
          </template>
        </el-alert>
      </div>
      <!--表格渲染-->
      <el-table class="tl-table" ref="mainTable" :height="300" resizable-key="tableHeight" :resizable-refs="tableResizeRefs" v-loading="loading" :data="datas" @selection-change="doSelectChange" @sort-change="doSortChange" @row-dblclick="doRowDbClick" @row-click="doRowClick" row-key="id" border fit :row-class-name="doChangeRowClassName">
        <el-table-column type="selection" width="55px" fixed="left"></el-table-column>
        <el-table-column prop="sortcode" label="序号" width="100px" sortable="custom" sort-by="sortcode" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="taskname" label="任务名称" width="150px" sortable="custom" sort-by="taskname" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="taskdetail" label="任务内容" sortable="custom" sort-by="taskdetail" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
      </el-table>
      <!-- 列表分页 -->
      <el-row class="pagebar" ref="pager">
        <el-pagination @size-change="doChangeSize" @current-change="doChangeIndex" :current-page="pageInfo.currentPage" :page-sizes="pageInfo.pageSizes" :total="pageInfo.totalCount" layout="total, sizes, prev, pager, next, jumper" background class="tl-table-pagination"> </el-pagination>
      </el-row>
      <tl-edit ref="editForm" @refresh="doRefresh" :parentId="parentId" :mileposttemplate="mileposttemplate"></tl-edit>
    </div>
  </div>
</template>

<script>
/** mixins */
import { mixin_list } from '@tapui/mixins/mixin_list'
import { filterObjectNull } from '@tapui/utils/util'
/** 子组件 */
import tlEdit from './edit'
/** 工具类 */
import { getAction, putAction, postAction, deleteAction } from '@tapui/utils/http'
export default {
  mixins: [mixin_list],
  components: { tlEdit },
  data() {
    return {
      description: '任务模板-列表查询',
      urlPrefix: '/sd/projectTaskTemplate/',
      url: {
        queryCodeList: '/sd/projectTaskTemplate/dataCodeList'
      },
      // 排序参数
      mileposttemplateid: '',
      // projecttype: '',
      // projectlevel: '',
      milepostname: '',
      rowData: {},
      editMilePostForm: {},
      sorterInfo: {
        sidx: 'sortcode',
        sord: 'asc'
      }
    }
  },
  props: {
    parentId: {
      type: [Number, String],
      default: ''
    },
    projecttype: {
      type: [String],
      default: ''
    },
    projectlevel: {
      type: [String],
      default: ''
    },
    mileposttemplate: {
      type: [String],
      default: ''
    },
    editable: {
      type: Boolean,
      default: true
    }
  },
  methods: {
    initPage() {
      if (this.editable) {
        this.rowDbClickActionType = 'edit'
      } else {
        this.rowDbClickActionType = 'view'
      }
    },
    beforeLoadData() {
      if (!this.parentId) {
        return false
      }
      this.queryParam.mileposttemplateid = this.parentId
      return true
    },
    getQueryParams() {
      let param = {}
      if (this.superQueryParams) {
        param['superQueryParams'] = encodeURI(this.superQueryParams)
      }
      Object.assign(param, this.queryParam, this.sorterInfo, this.filtersInfo)
      param.currentPage = this.pageInfo.currentPage
      param.pageSize = this.pageInfo.pageSize
      param.qry_mileposttemplateid = this.parentId
      return filterObjectNull(param)
    }
  }
}
</script>

<style scoped></style>

